﻿using Cms.Domain;
using NHibernate;

namespace Cms.Data.ORM
{
    public enum LogTypes
    {
        Create,
        Update,
        Delete
    }
    
    internal class AuditLog
    {
        public static void LogEvent(LogTypes logType, IAuditable entity,int administratorID, int userID, ISession session)
        {
            using (ISession tempSession = NHibernateSessionFactory.OpenSession(session.Connection))
            {
                var record = new AuditLogRecord(logType, entity.GetType().ToString(), entity.ID, entity.GetState(), administratorID, userID);
                tempSession.Save(record);
                tempSession.Flush();
            }
        }
    }
}